﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Iworld.Backstage.Framework
{
    public class IndexViewModel : MainFrameViewModelBase
    {

        int countOfClient;
        int countOfBackstage;
        public IndexViewModel()
            : base(Page.首页.ToString())
        {
            Storyboard sb = new Storyboard();
            sb.Duration = new Duration(new TimeSpan(0, 0, 4));
            sb.Completed += sb_Completed;
            sb.Begin();
            Refresh();
        }

        void sb_Completed(object sender, EventArgs e)
        {
            Refresh();
            (sender as Storyboard).Begin();
        }

        void Refresh()
        {
            CountOfClient = DataManager.GetValue<int>(DataKey.CountOfUsersInClient);
            CountOfBackstage = DataManager.GetValue<int>(DataKey.CountOfUsersInBackstage);
        }

        public int CountOfClient
        {
            get { return countOfClient; }
            set
            {
                if (this.countOfClient != value)
                {
                    this.countOfClient = value;
                    this.OnPropertyChanged("CountOfClient");
                }
            }
        }

        public int CountOfBackstage
        {
            get { return countOfBackstage; }
            set
            {
                if (this.countOfBackstage != value)
                {
                    this.countOfBackstage = value;
                    this.OnPropertyChanged("CountOfBackstage");
                }
            }
        }
    }
}
